<!DOCTYPE html>


<html lang="zh-Hans">


<head>
  <meta charset="utf-8" />
    
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />
  <title>
    powershell美化 |  Veal&#39;s Blog
  </title>
  <meta name="generator" content="hexo-theme-ayer">
  
  <link rel="shortcut icon" href="/favicon.ico" />
  
  
<link rel="stylesheet" href="/dist/main.css">

  
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/Shen-Yu/cdn/css/remixicon.min.css">

  
<link rel="stylesheet" href="/css/custom.css">

  
  
<script src="https://cdn.jsdelivr.net/npm/pace-js@1.0.2/pace.min.js"></script>

  
  

  

<link rel="alternate" href="/atom.xml" title="Veal's Blog" type="application/atom+xml">
<link href="https://cdn.bootcss.com/KaTeX/0.11.1/katex.min.css" rel="stylesheet" /></head>

</html>

<body>
  <div id="app">
    
      
    <main class="content on">
      <section class="outer">
  <article
  id="post-beautyposh"
  class="article article-type-post"
  itemscope
  itemprop="blogPost"
  data-scroll-reveal
>
  <div class="article-inner">
    
    <header class="article-header">
       
<h1 class="article-title sea-center" style="border-left:0" itemprop="name">
  powershell美化
</h1>
 

    </header>
     
    <div class="article-meta">
      <a href="/2020/07/25/beautyposh/" class="article-date">
  <time datetime="2020-07-25T08:09:31.000Z" itemprop="datePublished">2020-07-25</time>
</a> 
  <div class="article-category">
    <a class="article-category-link" href="/categories/%E6%8A%80%E6%9C%AF/">技术</a>
  </div>
  
<div class="word_count">
    <span class="post-time">
        <span class="post-meta-item-icon">
            <i class="ri-quill-pen-line"></i>
            <span class="post-meta-item-text"> Word count:</span>
            <span class="post-count">1.3k</span>
        </span>
    </span>

    <span class="post-time">
        &nbsp; | &nbsp;
        <span class="post-meta-item-icon">
            <i class="ri-book-open-line"></i>
            <span class="post-meta-item-text"> Reading time≈</span>
            <span class="post-count">4 min</span>
        </span>
    </span>
</div>
 
    </div>
      
    <div class="tocbot"></div>




  
    <div class="article-entry" itemprop="articleBody">
       
  <p>早上睁眼就收到阿里云服务器已过期的短信，但我都习惯了vscode + remotessh在linux上写各种HelloWorld了…主要爽在命令行的高效操作（rm -rf /*）和包管理，那么试试在win10下进行折腾~<br>主要思路为：<br>利用<a href="https://github.com/JanDeDobbeleer/oh-my-posh" target="_blank" rel="noopener">oh-my-posh</a>对powershell进行强化（命令行）<br>使用<a href="https://scoop.sh/" target="_blank" rel="noopener">scoop</a>进行包管理</p>
<a id="more"></a>

<h2 id="powershell篇"><a href="#powershell篇" class="headerlink" title="powershell篇"></a>powershell篇</h2><p>这里列一些必要的打卡及查看终端属性的方式。<br><strong>启动powershell</strong>：<br>win + r</p>
<div align="center"><img src="/images/beautyposh/cmd.png"></div>
确定后打开powershell
<div align="center"><img src="/images/beautyposh/shell.png"></div>

<p><strong>查看基本属性</strong>：<br>右键打开属性</p>
<div align="center"><img src="/images/beautyposh/settings.png"></div>
查看字体等属性
<div align="center"><img src="/images/beautyposh/font.png"></div>

<h3 id="安装更纱黑体"><a href="#安装更纱黑体" class="headerlink" title="安装更纱黑体"></a>安装更纱黑体</h3><p>powershell中的默认字体是新宋体，我们安装<a href="https://github.com/be5invis/Sarasa-Gothic" target="_blank" rel="noopener">更纱黑体</a>以解决中英文兼容问题</p>
<h4 id="从微软应用商店安装"><a href="#从微软应用商店安装" class="headerlink" title="从微软应用商店安装"></a>从微软应用商店安装</h4><p>点击<a href="https://www.microsoft.com/zh-cn/p/%E6%9B%B4%E7%BA%B1%E9%BB%91%E4%BD%93/9mw0m424ncz7?activetab=pivot:overviewtab" target="_blank" rel="noopener">更纱黑体页面</a>，选择安装进入到微软商店下载相关包即可。</p>
<h5 id="查看安装是否生效"><a href="#查看安装是否生效" class="headerlink" title="查看安装是否生效"></a>查看安装是否生效</h5><p>查看powershell字体属性，如正常安装，则可以看到更纱黑体系列字体。</p>
<div align="center"><img src="/images/beautyposh/font.png"></div>

<h3 id="调整配色"><a href="#调整配色" class="headerlink" title="调整配色"></a>调整配色</h3><h4 id="原生powershell"><a href="#原生powershell" class="headerlink" title="原生powershell"></a>原生powershell</h4><h5 id="前端大佬专用"><a href="#前端大佬专用" class="headerlink" title="前端大佬专用"></a>前端大佬专用</h5><p>原生powershell启动快，但配色方案也有限，对自己审美有自信，进入属性依次调整各项<br>总之我对自己的审美失去了自信…</p>
<div align="center"><img src="/images/beautyposh/myposh.png"></div>
<div align="center"><font size=2>powershell配色效果图</font></div>

<h5 id="使用ColorTool"><a href="#使用ColorTool" class="headerlink" title="使用ColorTool"></a>使用ColorTool</h5><p>当然还是使用配色模板更香啦<br>使用微软推出的<a href="https://github.com/microsoft/terminal/releases/tag/1904.29002" target="_blank" rel="noopener">ColorTool</a><br>解压后出现ColorTool.exe文件，运行即可。出于方便考虑，我们将ColorTool加入环境变量<br>按从左至右参考如图步骤添加ColorTool.exe所在文件夹至系统变量PATH中，并保存生效</p>
<div align="center"><img src="/images/beautyposh/env.png"></div>
<div align="center"><font size=2>不知道怎么配置环境变量的自行百度</font></div>

<p>在终端中查看colortool自带默认模板<br><em>命令</em> color -s<br>(透明度导致短选项不太清晰呢…)</p>
<div align="center"><img src="/images/beautyposh/default.png"></div>


<p>使用colortool将他人模板应用于powershell</p>
<div align="center"><img src="/images/beautyposh/template.png"></div>

<p>模板文件类型是itermcolors，可以在这个<a href="https://iterm2colorschemes.com/" target="_blank" rel="noopener">网站</a>下载<br>（你可能需要科学上网才能访问…）<br>打开喜欢的模板链接，将该页面保存为*.itermcolors（不要以txt结尾！）即可~</p>
<div align="center"><img src="/images/beautyposh/love.png"></div>

<h4 id="Fluent-Terminal"><a href="#Fluent-Terminal" class="headerlink" title="Fluent Terminal"></a>Fluent Terminal</h4><p>Fluent Terminal是备受推荐的第三方终端，据说启动速度相当优异，但我试了下…感觉和原生速度差得还是蛮远的…</p>
<h5 id="下载Fluent-Terminal"><a href="#下载Fluent-Terminal" class="headerlink" title="下载Fluent Terminal"></a>下载Fluent Terminal</h5><p>从<a href="https://www.microsoft.com/zh-cn/p/fluent-terminal/9p2krlmfxf9t?rtc=1&activetab=pivot:overviewtab" target="_blank" rel="noopener">微软商店</a>中进行获取或者在其页面进行<a href="https://github.com/felixse/FluentTerminal" target="_blank" rel="noopener">手动安装</a></p>
<p>成功安装后打开页面如下（还是相当漂亮的~而且支持多标签页呀！）</p>
<div align="center"><img src="/images/beautyposh/fluent.png" width=50%></div>

<p>进入属性页，改变字体为等纱黑体</p>
<div align="center"><img src="/images/beautyposh/ffont.png" width=50%></div>

<p>选择喜欢的模板</p>
<div align="center"><img src="/images/beautyposh/ftemp.png" width=50%></div>

<p>除了loveplace和MyBash是我导入的模板，其余均为系统内置，其实ubuntu和homebrew就相当好看啦</p>
<h6 id="彩蛋"><a href="#彩蛋" class="headerlink" title="彩蛋"></a>彩蛋</h6><p>Fluent Terminal还支持ssh，不过对于我已经装了openssh的这种用户来说，意义不大啦</p>
<div align="center"><img src="/images/beautyposh/ssh.png" width=50%></div>

<h3 id="安装oh-my-posh"><a href="#安装oh-my-posh" class="headerlink" title="安装oh-my-posh"></a>安装oh-my-posh</h3><p>现在安装<a href="https://github.com/JanDeDobbeleer/oh-my-posh" target="_blank" rel="noopener">oh-my-posh</a>真的很容易！<br>为了确保安装成功，在设置中应用开发者模式如下</p>
<div align="center"><img src="/images/beautyposh/dev.png" width=50%></div>

<p>并启动管理员powershell进行安装：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">Install-Module posh-git -Scope CurrentUser</span><br><span class="line">Install-Module oh-my-posh -Scope CurrentUser</span><br></pre></td></tr></table></figure>

<h4 id="创建配置文件"><a href="#创建配置文件" class="headerlink" title="创建配置文件"></a>创建配置文件</h4><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#</span><span class="bash"> 如果无配置文件 则创建</span></span><br><span class="line">if (!(Test-Path -Path $PROFILE )) &#123; New-Item -Type File -Path $PROFILE -Force &#125;</span><br><span class="line"><span class="meta">#</span><span class="bash"> 记事本打开</span></span><br><span class="line">notepad $PROFILE</span><br></pre></td></tr></table></figure>

<p>在记事本中添加如下内容</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">Import-Module posh-git </span><br><span class="line">Import-Module oh-my-posh </span><br><span class="line">Set-Theme Paradox # Paradox就是应用的主题 你也可以修改其他主题</span><br></pre></td></tr></table></figure>

<h4 id="应用oh-my-posh"><a href="#应用oh-my-posh" class="headerlink" title="应用oh-my-posh"></a>应用oh-my-posh</h4><p>为了能够成功应用，你需要进行授权</p>
<p>以管理员启动powershell</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">set-executionpolicy remotesigned</span><br></pre></td></tr></table></figure>

<p>然后再重新打开powershell，不出意外会成功生效</p>
<div align="center"><img src="/images/beautyposh/suc.png"></div>

<p>关于更多oh-my-posh主题及自定义主题介绍，可以参考<a href="https://sspai.com/post/52907" target="_blank" rel="noopener">少数派</a>这篇文章在配置文件里设置。</p>
<h3 id="在VSCode中应用oh-my-posh"><a href="#在VSCode中应用oh-my-posh" class="headerlink" title="在VSCode中应用oh-my-posh"></a>在VSCode中应用oh-my-posh</h3><p>如果直接打开VSCode，你会发现oh-my-posh主题的箭头不能正常显示，出现乱码。</p>
<p>其实是中英字体兼容的问题，在设置里，添加等纱黑体即可解决<br>（你一定要看蓝色部分）</p>
<div align="center"><img src="/images/beautyposh/vs.png"></div>

<p>不出意外的话，你也会看到美腻的内置终端</p>
<div align="center"><img src="/images/beautyposh/vsposh.png"></div>

<h2 id="包管理器-Scoop"><a href="#包管理器-Scoop" class="headerlink" title="包管理器 Scoop"></a>包管理器 Scoop</h2><p>其实我没有装Scoop，但我还是要大力推荐下，因为上述所说的oh-my-posh等都可以通过scoop来安装。</p>
<p>与debian下的apt、mac下的homebrew类似，scoop是windows下的包管理器，不过相比于chocolatey，它能够将应用隔离在ScoopApps中。</p>
<p>我吐槽下自己没法装Scoop的原因吧：</p>
<ol>
<li>Scoop是直接从官网下载的，如果不能高速科学上网，呵呵，自行体验下。<br>当然你也可以现装aria2嘿嘿，那样还是快一些的</li>
<li>默认安装在C盘用户目录下，有好处啊，比如省去配置环境变量的麻烦<br>但我就128G的SSD用来装系统盘…现在就剩30G了…平时只能软件装在500G的机械硬盘上…好了我也知道了为什么服务器全SSD盘装matlab好快，而我机械硬盘装了30min…</li>
</ol>
<p>（此处为废话：由此我得出结论了，如果你电脑是全SSD盘！那就不要分区！买个机械硬盘插在空仓位上存文件它不香么！）</p>
<p>以及，有钱有技术的大佬能不能搭个scoop国内镜像呀QAQ</p>
<p>参考博客</p>
<p><a href="https://sspai.com/post/52907" target="_blank" rel="noopener">少数派</a></p>
 
      <!-- reward -->
      
    </div>
    

    <!-- copyright -->
    
    <div class="declare">
      <ul class="post-copyright">
        <li>
          <i class="ri-copyright-line"></i>
          <strong>Copyright： </strong>
          Copyright is owned by the author. For commercial reprints, please contact the author for authorization. For non-commercial reprints, please indicate the source.
        </li>
      </ul>
    </div>
    
    <footer class="article-footer">
       
<div class="share-btn">
      <span class="share-sns share-outer">
        <i class="ri-share-forward-line"></i>
        分享
      </span>
      <div class="share-wrap">
        <i class="arrow"></i>
        <div class="share-icons">
          
          <a class="weibo share-sns" href="javascript:;" data-type="weibo">
            <i class="ri-weibo-fill"></i>
          </a>
          <a class="weixin share-sns wxFab" href="javascript:;" data-type="weixin">
            <i class="ri-wechat-fill"></i>
          </a>
          <a class="qq share-sns" href="javascript:;" data-type="qq">
            <i class="ri-qq-fill"></i>
          </a>
          <a class="douban share-sns" href="javascript:;" data-type="douban">
            <i class="ri-douban-line"></i>
          </a>
          <!-- <a class="qzone share-sns" href="javascript:;" data-type="qzone">
            <i class="icon icon-qzone"></i>
          </a> -->
          
          <a class="facebook share-sns" href="javascript:;" data-type="facebook">
            <i class="ri-facebook-circle-fill"></i>
          </a>
          <a class="twitter share-sns" href="javascript:;" data-type="twitter">
            <i class="ri-twitter-fill"></i>
          </a>
          <a class="google share-sns" href="javascript:;" data-type="google">
            <i class="ri-google-fill"></i>
          </a>
        </div>
      </div>
</div>

<div class="wx-share-modal">
    <a class="modal-close" href="javascript:;"><i class="ri-close-circle-line"></i></a>
    <p>扫一扫，分享到微信</p>
    <div class="wx-qrcode">
      <img src="//api.qrserver.com/v1/create-qr-code/?size=150x150&data=https://vealm.gitee.io/2020/07/25/beautyposh/" alt="微信分享二维码">
    </div>
</div>

<div id="share-mask"></div>  
  <ul class="article-tag-list" itemprop="keywords"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/%E7%8E%A9/" rel="tag">玩</a></li></ul>

    </footer>
  </div>

   
  <nav class="article-nav">
    
      <a href="/2020/07/27/UVaOJ0/" class="article-nav-link">
        <strong class="article-nav-caption">上一篇</strong>
        <div class="article-nav-title">
          
            暑期刷题之旅
          
        </div>
      </a>
    
    
      <a href="/2020/07/07/labjupyter/" class="article-nav-link">
        <strong class="article-nav-caption">下一篇</strong>
        <div class="article-nav-title">jupyterlab激活虚拟环境</div>
      </a>
    
  </nav>

   
<!-- valine评论 -->
<div id="vcomments-box">
  <div id="vcomments"></div>
</div>
<script src="//cdn1.lncld.net/static/js/3.0.4/av-min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/valine@1.4.14/dist/Valine.min.js"></script>
<script>
  new Valine({
    el: "#vcomments",
    app_id: "854ziDXtPQxK8dJf2vsosmzN-gzGzoHsz",
    app_key: "kV9lcyv3dVA2I6pqA4yd23p6",
    path: window.location.pathname,
    avatar: "monsterid",
    placeholder: "给我的文章加点评论吧~",
    recordIP: true,
  });
  const infoEle = document.querySelector("#vcomments .info");
  if (infoEle && infoEle.childNodes && infoEle.childNodes.length > 0) {
    infoEle.childNodes.forEach(function (item) {
      item.parentNode.removeChild(item);
    });
  }
</script>
<style>
  #vcomments-box {
    padding: 5px 30px;
  }

  @media screen and (max-width: 800px) {
    #vcomments-box {
      padding: 5px 0px;
    }
  }

  #vcomments-box #vcomments {
    background-color: #fff;
  }

  .v .vlist .vcard .vh {
    padding-right: 20px;
  }

  .v .vlist .vcard {
    padding-left: 10px;
  }
</style>

 
     
</article>

</section>
      <footer class="footer">
  <div class="outer">
    <ul>
      <li>
        Copyrights &copy;
        2020
        <i class="ri-heart-fill heart_icon"></i> Veal
      </li>
    </ul>
    <ul>
      <li>
        
        
        
        Powered by <a href="https://hexo.io" target="_blank">Hexo</a>
        <span class="division">|</span>
        Theme - <a href="https://github.com/Shen-Yu/hexo-theme-ayer" target="_blank">Ayer</a>
        
      </li>
    </ul>
    <ul>
      <li>
        
        
        <span>
  <span><i class="ri-user-3-fill"></i>Visitors:<span id="busuanzi_value_site_uv"></span></s>
  <span class="division">|</span>
  <span><i class="ri-eye-fill"></i>Views:<span id="busuanzi_value_page_pv"></span></span>
</span>
        
      </li>
    </ul>
    <ul>
      
    </ul>
    <ul>
      <li>
        <!-- cnzz统计 -->
        
        <script type="text/javascript" src='https://s9.cnzz.com/z_stat.php?id=1278599897&amp;web_id=1278599897'></script>
        
      </li>
    </ul>
  </div>
</footer>
      <div class="float_btns">
        <div class="totop" id="totop">
  <i class="ri-arrow-up-line"></i>
</div>

<div class="todark" id="todark">
  <i class="ri-moon-line"></i>
</div>

      </div>
    </main>
    <aside class="sidebar on">
      <button class="navbar-toggle"></button>
<nav class="navbar">
  
  <div class="logo">
    <a href="/"><img src="/images/ayer-side.svg" alt="Veal&#39;s Blog"></a>
  </div>
  
  <ul class="nav nav-main">
    
    <li class="nav-item">
      <a class="nav-item-link" href="/">主页</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/archives">归档</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/categories">分类</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/tags">标签</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/Me">关于我</a>
    </li>
    
  </ul>
</nav>
<nav class="navbar navbar-bottom">
  <ul class="nav">
    <li class="nav-item">
      
      <a class="nav-item-link nav-item-search"  title="Search">
        <i class="ri-search-line"></i>
      </a>
      
      
      <a class="nav-item-link" target="_blank" href="/atom.xml" title="RSS Feed">
        <i class="ri-rss-line"></i>
      </a>
      
    </li>
  </ul>
</nav>
<div class="search-form-wrap">
  <div class="local-search local-search-plugin">
  <input type="search" id="local-search-input" class="local-search-input" placeholder="Search...">
  <div id="local-search-result" class="local-search-result"></div>
</div>
</div>
    </aside>
    <script>
      if (window.matchMedia("(max-width: 768px)").matches) {
        document.querySelector('.content').classList.remove('on');
        document.querySelector('.sidebar').classList.remove('on');
      }
    </script>
    
    <!--加入音乐播放器-->

    <div id="mask"></div>

<!-- #reward -->
<div id="reward">
  <span class="close"><i class="ri-close-line"></i></span>
  <p class="reward-p"><i class="ri-cup-line"></i>请我喝杯咖啡吧~</p>
  <div class="reward-box">
    
    <div class="reward-item">
      <img class="reward-img" src="https://cdn.jsdelivr.net/gh/Shen-Yu/cdn/img/alipay.jpg">
      <span class="reward-type">支付宝</span>
    </div>
    
    
    <div class="reward-item">
      <img class="reward-img" src="https://cdn.jsdelivr.net/gh/Shen-Yu/cdn/img/wechat.jpg">
      <span class="reward-type">微信</span>
    </div>
    
  </div>
</div>
    
<script src="/js/jquery-2.0.3.min.js"></script>


<script src="/js/lazyload.min.js"></script>

<!-- Tocbot -->


<script src="/js/tocbot.min.js"></script>

<script>
  tocbot.init({
    tocSelector: '.tocbot',
    contentSelector: '.article-entry',
    headingSelector: 'h1, h2, h3, h4, h5, h6',
    hasInnerContainers: true,
    scrollSmooth: true,
    scrollContainer: 'main',
    positionFixedSelector: '.tocbot',
    positionFixedClass: 'is-position-fixed',
    fixedSidebarOffset: 'auto'
  });
</script>

<script src="https://cdn.jsdelivr.net/npm/jquery-modal@0.9.2/jquery.modal.min.js"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/jquery-modal@0.9.2/jquery.modal.min.css">
<script src="https://cdn.jsdelivr.net/npm/justifiedGallery@3.7.0/dist/js/jquery.justifiedGallery.min.js"></script>

<script src="/dist/main.js"></script>

<!-- ImageViewer -->

<!-- Root element of PhotoSwipe. Must have class pswp. -->
<div class="pswp" tabindex="-1" role="dialog" aria-hidden="true">

    <!-- Background of PhotoSwipe. 
         It's a separate element as animating opacity is faster than rgba(). -->
    <div class="pswp__bg"></div>

    <!-- Slides wrapper with overflow:hidden. -->
    <div class="pswp__scroll-wrap">

        <!-- Container that holds slides. 
            PhotoSwipe keeps only 3 of them in the DOM to save memory.
            Don't modify these 3 pswp__item elements, data is added later on. -->
        <div class="pswp__container">
            <div class="pswp__item"></div>
            <div class="pswp__item"></div>
            <div class="pswp__item"></div>
        </div>

        <!-- Default (PhotoSwipeUI_Default) interface on top of sliding area. Can be changed. -->
        <div class="pswp__ui pswp__ui--hidden">

            <div class="pswp__top-bar">

                <!--  Controls are self-explanatory. Order can be changed. -->

                <div class="pswp__counter"></div>

                <button class="pswp__button pswp__button--close" title="Close (Esc)"></button>

                <button class="pswp__button pswp__button--share" style="display:none" title="Share"></button>

                <button class="pswp__button pswp__button--fs" title="Toggle fullscreen"></button>

                <button class="pswp__button pswp__button--zoom" title="Zoom in/out"></button>

                <!-- Preloader demo http://codepen.io/dimsemenov/pen/yyBWoR -->
                <!-- element will get class pswp__preloader--active when preloader is running -->
                <div class="pswp__preloader">
                    <div class="pswp__preloader__icn">
                        <div class="pswp__preloader__cut">
                            <div class="pswp__preloader__donut"></div>
                        </div>
                    </div>
                </div>
            </div>

            <div class="pswp__share-modal pswp__share-modal--hidden pswp__single-tap">
                <div class="pswp__share-tooltip"></div>
            </div>

            <button class="pswp__button pswp__button--arrow--left" title="Previous (arrow left)">
            </button>

            <button class="pswp__button pswp__button--arrow--right" title="Next (arrow right)">
            </button>

            <div class="pswp__caption">
                <div class="pswp__caption__center"></div>
            </div>

        </div>

    </div>

</div>

<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/photoswipe@4.1.3/dist/photoswipe.min.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/photoswipe@4.1.3/dist/default-skin/default-skin.min.css">
<script src="https://cdn.jsdelivr.net/npm/photoswipe@4.1.3/dist/photoswipe.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/photoswipe@4.1.3/dist/photoswipe-ui-default.min.js"></script>

<script>
    function viewer_init() {
        let pswpElement = document.querySelectorAll('.pswp')[0];
        let $imgArr = document.querySelectorAll(('.article-entry img:not(.reward-img)'))

        $imgArr.forEach(($em, i) => {
            $em.onclick = () => {
                // slider展开状态
                // todo: 这样不好，后面改成状态
                if (document.querySelector('.left-col.show')) return
                let items = []
                $imgArr.forEach(($em2, i2) => {
                    let img = $em2.getAttribute('data-idx', i2)
                    let src = $em2.getAttribute('data-target') || $em2.getAttribute('src')
                    let title = $em2.getAttribute('alt')
                    // 获得原图尺寸
                    const image = new Image()
                    image.src = src
                    items.push({
                        src: src,
                        w: image.width || $em2.width,
                        h: image.height || $em2.height,
                        title: title
                    })
                })
                var gallery = new PhotoSwipe(pswpElement, PhotoSwipeUI_Default, items, {
                    index: parseInt(i)
                });
                gallery.init()
            }
        })
    }
    viewer_init()
</script>

<!-- MathJax -->

<script type="text/x-mathjax-config">
  MathJax.Hub.Config({
      tex2jax: {
          inlineMath: [ ['$','$'], ["\\(","\\)"]  ],
          processEscapes: true,
          skipTags: ['script', 'noscript', 'style', 'textarea', 'pre', 'code']
      }
  });

  MathJax.Hub.Queue(function() {
      var all = MathJax.Hub.getAllJax(), i;
      for(i=0; i < all.length; i += 1) {
          all[i].SourceElement().parentNode.className += ' has-jax';
      }
  });
</script>

<script src="https://cdn.jsdelivr.net/npm/mathjax@2.7.6/unpacked/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
<script>
  var ayerConfig = {
    mathjax: true
  }
</script>

<!-- Katex -->


    
        <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.11.1/dist/katex.min.css">
        <script src="https://cdn.jsdelivr.net/npm/katex@0.11.1/dist/katex.min.js"></script>
        <script src="https://cdn.jsdelivr.net/npm/katex@0.11.1/dist/contrib/auto-render.min.js"></script>
        
    


<!-- busuanzi  -->


<script src="/js/busuanzi-2.3.pure.min.js"></script>


<!-- ClickLove -->

<!-- ClickBoom1 -->

<!-- ClickBoom2 -->

<!-- CodeCopy -->


<link rel="stylesheet" href="/css/clipboard.css">

<script src="https://cdn.jsdelivr.net/npm/clipboard@2/dist/clipboard.min.js"></script>
<script>
  function wait(callback, seconds) {
    var timelag = null;
    timelag = window.setTimeout(callback, seconds);
  }
  !function (e, t, a) {
    var initCopyCode = function(){
      var copyHtml = '';
      copyHtml += '<button class="btn-copy" data-clipboard-snippet="">';
      copyHtml += '<i class="ri-file-copy-2-line"></i><span>COPY</span>';
      copyHtml += '</button>';
      $(".highlight .code pre").before(copyHtml);
      $(".article pre code").before(copyHtml);
      var clipboard = new ClipboardJS('.btn-copy', {
        target: function(trigger) {
          return trigger.nextElementSibling;
        }
      });
      clipboard.on('success', function(e) {
        let $btn = $(e.trigger);
        $btn.addClass('copied');
        let $icon = $($btn.find('i'));
        $icon.removeClass('ri-file-copy-2-line');
        $icon.addClass('ri-checkbox-circle-line');
        let $span = $($btn.find('span'));
        $span[0].innerText = 'COPIED';
        
        wait(function () { // 等待两秒钟后恢复
          $icon.removeClass('ri-checkbox-circle-line');
          $icon.addClass('ri-file-copy-2-line');
          $span[0].innerText = 'COPY';
        }, 2000);
      });
      clipboard.on('error', function(e) {
        e.clearSelection();
        let $btn = $(e.trigger);
        $btn.addClass('copy-failed');
        let $icon = $($btn.find('i'));
        $icon.removeClass('ri-file-copy-2-line');
        $icon.addClass('ri-time-line');
        let $span = $($btn.find('span'));
        $span[0].innerText = 'COPY FAILED';
        
        wait(function () { // 等待两秒钟后恢复
          $icon.removeClass('ri-time-line');
          $icon.addClass('ri-file-copy-2-line');
          $span[0].innerText = 'COPY';
        }, 2000);
      });
    }
    initCopyCode();
  }(window, document);
</script>


<!-- CanvasBackground -->


    
  </div>
</body>

</html>